package com.xusheng.cli.tools;

import java.util.Random;

public class InviteCodeUtils {

    public static String generateCode() {
        String charList = "ABCDEFGHIJKLMNPQRSTUVWXY";
        String numList = "0123456789";
        String rev = "";
        int maxNumCount = 4;
        int length = 6;
        Random f = new Random();
        for (int i = 0; i < length; i++) {
            if (f.nextBoolean() && maxNumCount > 0) {
                maxNumCount--;
                rev += numList.charAt(Math.abs(f.nextInt()) % numList.length());
            } else {
                rev += charList.charAt(Math.abs(f.nextInt()) % charList.length());
            }
        }
        return rev;
    }

    public static void main(String[] args) {
//        String serialCode = toSerialCode(1660463663403655170l);
        String serialCode = generateCode();
        System.out.println(serialCode);
//        long id = codeToId("hnahhra8nrvt");
//        System.out.println(id);
    }
}
